package com.flying.invest.strategy.model;

import java.util.Date;

import com.flying.common.util.Codes;
import com.flying.framework.annotation.ConstantEnum;
import com.flying.framework.annotation.Param;
import com.flying.framework.annotation.ServiceField;
import com.flying.framework.annotation.ServiceFieldParam;
import com.flying.framework.data.Data;
import com.flying.framework.data.DataSerializable;
import com.flying.framework.metadata.Meta;

@SuppressWarnings("serial")
@Meta(id="i_strategy",title="资产类型", table="i_strategy", primaryKeys={"strategy_id"})
public class Strategy extends Data implements DataSerializable {
	public final static String ENTITY_NAME = "i_strategy";
	
	public final static String STRATEGY_ID = "strategy_id";
	public final static String USER_ID = "user_id";
	public final static String TYPE_ID = "type_id";
	public final static String INVEST_ID = "invest_id";
	public final static String ASSETS_ID = "assets_id";
	public final static String NAME = "name";
	public final static String REMARKS = "remarks";
	public final static String SCOPE = "scope";
	public final static String STATUS = "status";
	public final static String EFFECTIVE_FROM = "effective_from";
	public final static String EFFECTIVE_TO = "effective_to";
	public final static String BATCH_NUM = "batch_num";
	public final static String EXECUTE_TIME = "execute_time";
	public final static String CREATOR = "creator";
	public final static String CREATE_TIME = "create_time";
	public final static String UPDATOR = "updator";
	public final static String UPDATE_TIME = "update_time";

	public enum Status implements ConstantEnum<Integer> {
		PREPARING(0, "暂停"), PROCESSING(1, "执行中"), PROCESSING_FOR_SELL(3, "执行中(仅卖出)"), OVER(2, "已结束");

		public final int value;
		public final String remarks;

		Status(int value, String remarks) {
			this.value = value;
			this.remarks = remarks;
		}
		
		@Override
		public Integer value() {
			return this.value;
		}

		@Override
		public String text() {
			return remarks;
		}
	}
	
	public enum Scope implements ConstantEnum<Integer> {
		STRATEGY_SCOPE(0, "策略范围"), INVESTMENT_SCOPE(1, "项目范围"), USER_SCOPE(2, "用户范围");

		public final int value;
		public final String remarks;

		Scope(int value, String remarks) {
			this.value = value;
			this.remarks = remarks;
		}
		
		@Override
		public Integer value() {
			return this.value;
		}

		@Override
		public String text() {
			return remarks;
		}
	}
	
	@Param(value=STRATEGY_ID,   required=true,   maxlength=0,	desc="策略ID" , generator=Codes.AUTO_INCREMENT)
	private Long strategyId;
	
	@Param(value=USER_ID,   required=true,   maxlength=0,	desc="所属用户" )
	private Long userId;
	
	@Param(value=TYPE_ID,   required=true,   maxlength=0,	desc="策略类型" )
	private Long typeId;
	
	@Param(value=INVEST_ID,   required=true,   maxlength=0,	desc="投资项目" )
	private Long investId;
	
	@Param(value=ASSETS_ID,   required=true,   maxlength=0,	desc="投资品种" )
	private Long assetsId;
	
	@Param(value=NAME,   required=false,   maxlength=50,	desc="名称" )
	private String name;
	
	@Param(value=REMARKS,   required=false,   maxlength=400,	desc="说明" )
	private String remarks;
	
	@Param(value=SCOPE,   required=false,   maxlength=0,	desc="范围" )
	private Integer scope;
	
	@Param(value=STATUS,   required=false,   maxlength=0,	desc="状态" )
	private Integer status;
	
	@Param(value=EFFECTIVE_FROM,   required=false,   maxlength=0,	desc="生效时间" )
	private Date effectiveFrom;
	
	@Param(value=EFFECTIVE_TO,   required=false,   maxlength=0,	desc="失效时间" )
	private Date effectiveTo;
	
	@Param(value=BATCH_NUM,   required=false,   maxlength=0,	desc="最后批号" )
	private Integer batchNum;
	
	@Param(value=EXECUTE_TIME,   required=false,   maxlength=0,	desc="执行时间" )
	private Date executeTime;
	
	@Param(value=CREATOR,   required=false,   maxlength=40,	desc="创建人" )
	private String creator;
	
	@Param(value=CREATE_TIME,   required=false,   maxlength=0,	desc="创建时间" )
	private Date createTime;
	
	@Param(value=UPDATOR,   required=false,   maxlength=40,	desc="修改人" )
	private String updator;
	
	@Param(value=UPDATE_TIME,   required=false,   maxlength=0,	desc="修改时间" )
	private Date updateTime;

	@ServiceField(serviceId="StrategyTypeService:findById", params={@ServiceFieldParam(param=StrategyType.TYPE_ID, value="$"+TYPE_ID)})
	@Param(value="strategyType",   required=false,	desc="策略类型")
	private StrategyType strategyType;

	@ServiceField(serviceId="StrategyService:findConfigById", params={@ServiceFieldParam(param=Strategy.STRATEGY_ID, value="$"+STRATEGY_ID)})
	@Param(value="strategyConfig",   required=false,	desc="策略配置")
	private Data strategyConfig;
	
	public Long getStrategyId() {
		return this.strategyId;
	}
	
	public void setStrategyId(Long strategyId) {
		this.strategyId = strategyId;
	}
	
	public Long getUserId() {
		return this.userId;
	}
	
	public void setUserId(Long userId) {
		this.userId = userId;
	}
	
	public Long getTypeId() {
		return this.typeId;
	}
	
	public void setTypeId(Long typeId) {
		this.typeId = typeId;
	}
	
	public Long getInvestId() {
		return this.investId;
	}
	
	public void setInvestId(Long investId) {
		this.investId = investId;
	}
	
	public Long getAssetsId() {
		return assetsId;
	}

	public void setAssetsId(Long assetsId) {
		this.assetsId = assetsId;
	}

	public String getName() {
		return this.name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getRemarks() {
		return this.remarks;
	}
	
	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}
	
	public Integer getScope() {
		return this.scope;
	}
	
	public void setScope(Integer scope) {
		this.scope = scope;
	}
	
	public Integer getStatus() {
		return this.status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Date getEffectiveFrom() {
		return this.effectiveFrom;
	}
	
	public void setEffectiveFrom(Date effectiveFrom) {
		this.effectiveFrom = effectiveFrom;
	}
	
	public Date getEffectiveTo() {
		return this.effectiveTo;
	}
	
	public void setEffectiveTo(Date effectiveTo) {
		this.effectiveTo = effectiveTo;
	}
	
	public Integer getBatchNum() {
		return this.batchNum;
	}
	
	public void setBatchNum(Integer batchNum) {
		this.batchNum = batchNum;
	}
	
	public Date getExecuteTime() {
		return executeTime;
	}

	public void setExecuteTime(Date executeTime) {
		this.executeTime = executeTime;
	}

	public String getCreator() {
		return this.creator;
	}
	
	public void setCreator(String creator) {
		this.creator = creator;
	}
	
	public Date getCreateTime() {
		return this.createTime;
	}
	
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	
	public String getUpdator() {
		return this.updator;
	}
	
	public void setUpdator(String updator) {
		this.updator = updator;
	}
	
	public Date getUpdateTime() {
		return this.updateTime;
	}
	
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	//
	public StrategyType getStrategyType() {
		return strategyType;
	}

	public Data getStrategyConfig() {
		return strategyConfig;
	}
	
	public String getStrategyTypeName() {
		StrategyType t = this.getStrategyType();
		return t == null?null: t.getName();
	}
}